package com.sdb.schedule.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdb.common.annotation.Log;
import com.sdb.common.core.controller.BaseController;
import com.sdb.common.core.domain.AjaxResult;
import com.sdb.common.enums.BusinessType;
import com.sdb.schedule.domain.TdSchedule;
import com.sdb.schedule.service.ITdScheduleService;
import com.sdb.common.utils.poi.ExcelUtil;
import com.sdb.common.core.page.TableDataInfo;

/**
 * 排班信息Controller
 * 
 * @author yyh
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/schedule/schedulelist")
public class TdScheduleController extends BaseController
{
    @Autowired
    private ITdScheduleService tdScheduleService;

    /**
     * 查询排班信息列表
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @GetMapping("/list")
    public TableDataInfo list(TdSchedule tdSchedule)
    {
        startPage();
        List<TdSchedule> list = tdScheduleService.selectTdScheduleList(tdSchedule);
        return getDataTable(list);
    }


    /**
     * 导出排班信息列表
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "排班信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdSchedule tdSchedule)
    {
        List<TdSchedule> list = tdScheduleService.selectTdScheduleList(tdSchedule);
        ExcelUtil<TdSchedule> util = new ExcelUtil<TdSchedule>(TdSchedule.class);
        util.exportExcel(response, list, "排班信息数据");
    }

    /**
     * 获取排班信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tdScheduleService.selectTdScheduleById(id));
    }

    /**
     * 新增排班信息
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "排班信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdSchedule tdSchedule)
    {
        return toAjax(tdScheduleService.insertTdSchedule(tdSchedule));
    }

    /**
     * 修改排班信息
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "排班信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdSchedule tdSchedule)
    {
        return toAjax(tdScheduleService.updateTdSchedule(tdSchedule));
    }

    /**
     * 删除排班信息
     */
    @PreAuthorize("@ss.hasPermi('index')")
    @Log(title = "排班信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdScheduleService.deleteTdScheduleByIds(ids));
    }


}
